<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import { mapState } from 'vuex';
import { getToken, getCookieTenant, getOidcUser } from '@/lib/auth';
import { loginOidc } from '@/lib/oidc_fun';
export default {
  name: 'App',
  computed: {
    ...mapState({
      tokenInfo: state => state.user.token || getToken()
    })
  },
  created() {
    console.log(this.tokenInfo);
    if (this.tokenInfo) {
      const user = getOidcUser();
      if (!user) {
        const href = window.location.href;
        let tenantId = getCookieTenant() ? getCookieTenant() : '';
        tenantId = tenantId + '___' + ENVIR;
        loginOidc({
          state: window.btoa(href),
          acr_values: tenantId ? window.btoa(tenantId) : ''
        }); // 跳转登录
      }
    }
  }
};
</script>
